package qjc.n_贪心算法;

public class n2_跳跃游戏 {
    public boolean canJump(int[] nums) {
        int n = nums.length;
        int maxNum = 0;
        for (int i = 0; i < n; i++) {
            if (i > maxNum) {
                return false;
            }
            maxNum = Math.max(maxNum, nums[i] + i);
            if (maxNum >= n - 1) {
                return true;
            }
        }
        return maxNum >= n - 1;
    }
}
